package com.briup.estore.web.controller;

import com.briup.estore.service.AddressService;
import com.briup.estore.vo.AddressVO;
import com.briup.estore.web.response.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@Api(tags = "地址模块")
@RequestMapping("/address")
public class AddressController {
    @Autowired
    private AddressService addressService;

    @GetMapping("")
    @ApiOperation("获取用户的所有收货地址")
    public Result address(HttpServletRequest request) {
        String userId = (String) request.getAttribute("userId");
        List<AddressVO> adress = addressService.address(userId);
        return Result.success(adress);
    }
}
